package com.hopes.bizz.risk.transfer.converter;

import com.hopes.bizz.risk.control.entity.RiskMeasureTaskEntity;
import com.hopes.bizz.risk.transfer.bean.dto.RiskMeasuresTaskDto;
import com.hopes.bizz.risk.transfer.converter.expression.CommonExp;
import com.hopes.bizz.risk.transfer.converter.expression.RiskMeasuresTaskExp;
import org.mapstruct.BeanMapping;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

/**
 * @author lyb
 * @version 1.0
 * @date 2024/2/4 14:04
 */
@Mapper(uses = {CommonExp.class, RiskMeasuresTaskExp.class})
public interface RiskMeasuresTaskConverter {

    RiskMeasuresTaskConverter INSTANCE = Mappers.getMapper(RiskMeasuresTaskConverter.class);

    @Mapping(target = "uid", source = "id")
    @Mapping(target = "delFlag", source = "deleted", defaultValue = "0")
    @Mapping(target = "createTime", source = "createDate", dateFormat = "yyyy-MM-dd HH:mm:ss")
    @Mapping(target = "createBy", source = "createBy")
    @Mapping(target = "updateTime", source = "updateDate", dateFormat = "yyyy-MM-dd HH:mm:ss")
    @Mapping(target = "updateBy", source = "updateBy")
    @Mapping(target = "checkContent", source = "troubleshootContent")
    @Mapping(target = "checkCycle", source = "checkCycle", qualifiedByName = "integerConverter")
    @Mapping(target = "checkCycleType", source = "checkCycleUnit", qualifiedByName = "checkCycleType")
    @Mapping(target = "startCheckDate", source = "taskStartTime", dateFormat = "yyyy-MM-dd HH:mm:ss")
    @Mapping(target = "workStartTime", source = "workStartTime")
    @Mapping(target = "workEndTime", source = "workEndTime")
    @Mapping(target = "workDayType", source = "workDayType", qualifiedByName = "integerConverter")
    @Mapping(target = "workType", source = "workType", qualifiedByName = "integerConverter")
    @Mapping(target = "taskNum", source = "taskNum", qualifiedByName = "integerConverter")
    @BeanMapping(ignoreByDefault = true)
    RiskMeasureTaskEntity toEntity(RiskMeasuresTaskDto riskMeasuresTaskDto);
}
